home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
-
- class Set(object):
- __slots__ = [
- 'items']
-
- def __init__(self, items = None):
- self.items = []
- if items is not None:
- for item in items:
- self.add(item)
-
-
-
-
- def __repr__(self):
- return 'dns.simpleset.Set(%s)' % repr(self.items)
-
-
- def add(self, item):
- if item not in self.items:
- self.items.append(item)
-
-
-
- def remove(self, item):
- self.items.remove(item)
-
-
- def discard(self, item):
-
- try:
- self.items.remove(item)
- except ValueError:
- pass
-
-
-
- def _clone(self):
- cls = self.__class__
- obj = cls.__new__(cls)
- obj.items = list(self.items)
- return obj
-
-
- def __copy__(self):
- return self._clone()
-
-
- def copy(self):
- return self._clone()
-
-
- def union_update(self, other):
- if not isinstance(other, Set):
- raise ValueError, 'other must be a Set instance'
-
- if self is other:
- return None
-
- for item in other.items:
- self.add(item)
-
-
-
- def intersection_update(self, other):
- if not isinstance(other, Set):
- raise ValueError, 'other must be a Set instance'
-
- if self is other:
- return None
-
- for item in list(self.items):
- if item not in other.items:
- self.items.remove(item)
- continue
-
-
-
- def difference_update(self, other):
- if not isinstance(other, Set):
- raise ValueError, 'other must be a Set instance'
-
- if self is other:
- self.items = []
- else:
- for item in other.items:
- self.discard(item)
-
-
-
- def union(self, other):
- obj = self._clone()
- obj.union_update(other)
- return obj
-
-
- def intersection(self, other):
- obj = self._clone()
- obj.intersection_update(other)
- return obj
-
-
- def difference(self, other):
- obj = self._clone()
- obj.difference_update(other)
- return obj
-
-
- def __or__(self, other):
- return self.union(other)
-
-
- def __and__(self, other):
- return self.intersection(other)
-
-
- def __add__(self, other):
- return self.union(other)
-
-
- def __sub__(self, other):
- return self.difference(other)
-
-
- def __ior__(self, other):
- self.union_update(other)
- return self
-
-
- def __iand__(self, other):
- self.intersection_update(other)
- return self
-
-
- def __iadd__(self, other):
- self.union_update(other)
- return self
-
-
- def __isub__(self, other):
- self.difference_update(other)
- return self
-
-
- def update(self, other):
- for item in other:
- self.add(item)
-
-
-
- def clear(self):
- self.items = []
-
-
- def __eq__(self, other):
- for item in self.items:
- if item not in other.items:
- return False
- continue
-
- for item in other.items:
- if item not in self.items:
- return False
- continue
-
- return True
-
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
-
- def __len__(self):
- return len(self.items)
-
-
- def __iter__(self):
- return iter(self.items)
-
-
- def __getitem__(self, i):
- return self.items[i]
-
-
- def __delitem__(self, i):
- del self.items[i]
-
-
- def __getslice__(self, i, j):
- return self.items[i:j]
-
-
- def __delslice__(self, i, j):
- del self.items[i:j]
-
-
- def issubset(self, other):
- if not isinstance(other, Set):
- raise ValueError, 'other must be a Set instance'
-
- for item in self.items:
- if item not in other.items:
- return False
- continue
-
- return True
-
-
- def issuperset(self, other):
- if not isinstance(other, Set):
- raise ValueError, 'other must be a Set instance'
-
- for item in other.items:
- if item not in self.items:
- return False
- continue
-
- return True
-
-
-